<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:r="http://ricchieri.com/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>


	<ui:composition template="../../templates/commonLayoutReservation.xhtml">
		<ui:define name="title">#{msg.titleReservation}</ui:define>
		<ui:define name="content">
			<h2>#{msg.editReservation}</h2>
			
			<h:form id="messagesForm">
				<p:messages showDetail="false" autoUpdate="true" closable="false" severity="fatal"/>
			</h:form>
			 
			<h:form id="editForm">
			
				<p:fieldset legend="#{msg.eventTime}" toggleable="false" id="fieldSetSchedule" style="margin-top:10px">
					<h:panelGrid columns="2">
						<h:outputLabel style="font-weight:bold" value="#{msg.date}" />
			            <h:outputLabel value="#{editReservationMB.formatDate(editReservationMB.reservation.scheduleCharter.schedule.date)}" />
			            
			            <h:outputLabel style="font-weight:bold" value="#{msg.time}" />
			            <h:outputLabel value="#{editReservationMB.reservation.scheduleCharter.schedule.time}" />
		
			            <h:outputLabel style="font-weight:bold" value="#{msg.tripOrientation}" />
			            <h:outputLabel value="#{editReservationMB.reservation.scheduleCharter.trip.getFormatTrip()}" />
	 
						<h:outputLabel style="font-weight:bold" value="#{msg.charterNumber}" />
						<h:outputLabel value="#{editReservationMB.reservation.scheduleCharter.charter.charterNumber}" />  
			
						<h:outputLabel style="font-weight:bold" value="#{msg.charterType}"/>
						<h:outputLabel value="#{editReservationMB.obtainDescription(editReservationMB.reservation.scheduleCharter.charter.charterType.description)}" /> 
		
						<h:outputLabel style="font-weight:bold" value="#{msg.charterPlaces}"/>
						<h:outputLabel value="#{editReservationMB.reservation.scheduleCharter.charter.places}" />   
			
						<h:outputLabel style="font-weight:bold" value="#{msg.scheduleDriver}"/>
						<h:outputLabel value="#{editReservationMB.reservation.scheduleCharter.user.getFullName()}" />
					</h:panelGrid>
					
					<div style="text-align:right">
						<p:commandLink oncomplete="eventDialog.show();" ajax="true" styleClass="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only button-action">
			        		<span class="ui-button-text ui-c"><i class="icon-calendar"></i><r:space/><r:space/>#{msg.edit}</span>
			        	</p:commandLink>
					</div>
				</p:fieldset>
				
				<p:fieldset legend="#{msg.passengerData}" toggleable="false" id="fieldSetPassanger" style="margin-top:10px">
					<h:panelGrid columns="2">
					
						<h:outputLabel style="font-weight:bold" value="#{msg.full_name}" />
			     		<h:outputLabel value="#{editReservationMB.reservation.user.getFullName()}"/>
			     			    
					    <h:outputLabel style="font-weight:bold" value="#{msg.documentType}" />
					    <h:outputLabel value="#{editReservationMB.obtainDescription(editReservationMB.reservation.user.documentType.description)}"/>
			            
			     		<h:outputLabel style="font-weight:bold" value="#{msg.documentNum}" />
					    <h:outputLabel value="#{editReservationMB.reservation.user.dni}"/>
					</h:panelGrid>

				</p:fieldset>
				
				<p:fieldset legend="#{msg.otherData}" toggleable="false" id="fieldSetReservationData" style="margin-top:10px">
					<h:panelGrid columns="3">	
		       	 		<h:outputLabel style="font-weight:bold" value="#{msg.reservationType}"/>
		       	 		<p:selectOneMenu value="#{editReservationMB.selectedReservationType}" id="reservationType">
							<f:selectItems value="#{editReservationMB.reservationType}" />
						</p:selectOneMenu>
						<p:message id="reservationTypeMsg" for="reservationType" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.passengerType}"/>
		       	 		<p:selectOneMenu value="#{editReservationMB.selectedPassengerType}" id="passengerType">
							<f:selectItems value="#{editReservationMB.passengerType}" />
						</p:selectOneMenu>
						<p:message id="passengerTypeMsg" for="passengerType" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.meanPayment}"/>
		       	 		<p:selectOneMenu value="#{editReservationMB.selectedMeanPayment}" id="meanPayment">
							<f:selectItems value="#{editReservationMB.meanPayment}" />
						</p:selectOneMenu>
						<p:message id="meanPaymentMsg" for="meanPayment" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.tripPrice}"/>
						<p:inputText id="tripPrice" value="#{editReservationMB.reservation.cost}" maxlength="5" onkeypress="return isDecimalNumberKey(event)"/>
						<p:message id="tripPriceMsg" for="tripPrice" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.upOn}"/>
						<p:inputText id="upOn" value="#{editReservationMB.reservation.upOn}" maxlength="50" required="true" requiredMessage="#{msg.requiredUpOn}"/>
						<p:message id="upOnMsg" for="upOn" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.downOn}"/>
						<p:inputText id="downOn" value="#{editReservationMB.reservation.downOn}" maxlength="50" required="true" requiredMessage="#{msg.requiredDownOn}"/>
						<p:message id="downOnMsg" for="downOn" display="icon"/>
						
						<h:outputLabel style="font-weight:bold" value="#{msg.reservationComments}"/>
						<p:inputTextarea rows="6" style="width:90%" id="observation" value="#{editReservationMB.reservation.observation}" maxlength="500" autoResize="false"/>
						<p:message id="observationMsg" for="observation" display="icon"/>
				
					</h:panelGrid>
				
				</p:fieldset>
				
				<h:panelGrid columns="2" style="margin-top:10px; text-align:center">
			     	<p:commandButton id="cancel" value="#{msg.cancelButton}" action="#{editReservationMB.doBackToSearchReservation()}" ajax="false" styleClass="button-action green"/>
		     		<p:commandButton id="saveReservation" value="#{msg.saveButton}" action="#{editReservationMB.saveReservation()}" ajax="false" styleClass="button-action green"/>
		     	</h:panelGrid>
		     	
		     	<p:dialog id="eventDialog" widgetVar="eventDialog" header="#{msg.eventDetails}" showEffect="clip" hideEffect="clip" maximizable="false" minimizable="false" resizable="false">
	     			<p:scrollPanel style="width:90em;height:50em" mode="native"> 
						<h:outputLabel value="#{msg.capacity}" style="text-align:center; width:100%"/>
						<p:panelGrid columns="4" style="margin-bottom:10px;text-align: center;">
							<p:outputPanel>
								<span class="full-capacity">Empty</span>
								<h:outputLabel value="#{msg.fullCapacity}"/>
							</p:outputPanel>
							
							<p:outputPanel>
								<span class="low-capacity">Empty</span>
								<h:outputLabel value="#{msg.lowCapacity}"/>
							</p:outputPanel>
							
							<p:outputPanel>
								<span class="medium-capacity">Empty</span>
								<h:outputLabel value="#{msg.mediumCapacity}"/>
							</p:outputPanel>
							
							<p:outputPanel>
								<span class="high-capacity">Empty</span>
								<h:outputLabel value="#{msg.highCapacity}"/>
							</p:outputPanel>
						</p:panelGrid>
						<h:panelGrid columns="2">
							<h:outputLabel value="#{msg.tripOrientation}" />
							<p:selectOneMenu value="#{editReservationMB.scheduleCharterFilter.trip}">
								<f:selectItems value="#{editReservationMB.trips}" />
								<p:ajax listener="#{editReservationMB.changeTrip}" update="schedule"/>
							</p:selectOneMenu>
						</h:panelGrid>
						<p:schedule id="schedule" value="#{editReservationMB.scheduleLazyModel}" draggable="false" resizable="false" widgetVar="myschedule" style="padding-top:15px;" timeFormat="HH:mm">  
							<p:ajax event="eventSelect" listener="#{editReservationMB.onEventSelect}" oncomplete="eventDialog.hide();" update="@form :editForm"/> 
						</p:schedule>
	     			</p:scrollPanel>
		     	</p:dialog>
		     	
			</h:form>
		</ui:define>
	</ui:composition>
</h:body>
</html>
